package com.sdry.product.common.service;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sdry.product.common.controller.HalfProductStockController;
import com.sdry.product.common.entity.HalfProductStock;
import com.sdry.product.common.mapper.HalfProductStockMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Description 半成品库存
 * @Author chenBin
 * @Date 2020-03-23 15:43
 * @Version 1.0
 **/
@Service
@Transactional(rollbackFor = Exception.class)
public class HalfProductStockServiceImpl implements HalfProductStockService{

    /**注册服务**/
    @Resource
    private HalfProductStockMapper halfProductStockMapper;

    /**
     * 分页查询
     * @param halfProductStock
     * @return
     */
    @Override
    public IPage<HalfProductStock> queryHalfProductStockPage(HalfProductStock halfProductStock) {
        IPage<HalfProductStock> page = new Page<>(halfProductStock.getPage(),halfProductStock.getLimit());
        QueryWrapper<HalfProductStock> queryWrapper = new QueryWrapper<>();
        if (StringUtils.isNotBlank(halfProductStock.getCnumber())) queryWrapper.like("cnumber",halfProductStock.getCnumber());
        IPage<HalfProductStock> halfProductStockIPage = halfProductStockMapper.selectPage(page, queryWrapper);
        return halfProductStockIPage;
    }

    /**
     * 总数
     * @param halfProductStock 对象
     * @return Long
     */
    @Override
    public Long queryHalfProductStockTotal(HalfProductStock halfProductStock) {
        return null;
    }
}
